[main]
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet

    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet

    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl
<% if @cert_name != @fqdn -%>

    # The locally unique name for this node.
    # (if you aren’t using DNS names)
    certname = <%= @cert_name %>
<% end -%>

[agent]
    # The file in which puppetd stores a list of the classes
    # associated with the retrieved configuratiion.  Can be loaded in
    # the separate ``puppet`` executable using the ``--loadclasses``
    # option.
    # The default value is '$confdir/classes.txt'.
    classfile = $vardir/classes.txt

    # Where puppetd caches the local configuration.  An
    # extension indicating the cache format is added automatically.
    # The default value is '$confdir/localconfig'.
    localconfig = $vardir/localconfig

    # The environment Puppet is running in.
    # For servers (i.e. puppet master) this provides the default
    # environment for nodes we know nothing about.
    # The default value is 'production'.<% 
  if scope.lookupvar('agentenv').length > 0
    # if agentenv is set up, use that
    curenv = agentenv
  else
    # else use environment, or if environment is not set, fall back to 'production' as default
    curenv = scope.lookupvar('environment').length > 0 ? scope.lookupvar('environment') : 'production'
  end
%>
    environment = <%= curenv %>
